﻿project ("FAQ")

file(GLOB_RECURSE SRC_DIR_LIST "*.h" "*.hpp" "*.cpp")

add_library(${PROJECT_NAME} SHARED ${SRC_DIR_LIST})

target_include_directories(${PROJECT_NAME} PRIVATE
"${CMAKE_SOURCE_DIR}/yzrutil/main"
${PROJECT_SOURCE_DIR}
)

target_precompile_headers(${PROJECT_NAME} PRIVATE FAQ.h)

set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}")
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

if(WIN32)
    # 设置字符集相关选项
    target_compile_definitions(${PROJECT_NAME} PRIVATE
        UNICODE
        _UNICODE
        _CRT_SECURE_NO_WARNINGS
    )
    
    # 设置链接器选项
    set_target_properties(${PROJECT_NAME} PROPERTIES
        LINK_FLAGS "/MANIFEST:NO /LTCG"
    )
    
    # 确保资源编译器使用正确的编码
    set_source_files_properties(resource/win32resource.rc PROPERTIES
        COMPILE_FLAGS "/c65001"
    )
endif()

target_link_libraries(${PROJECT_NAME} PRIVATE yzrutil)

if(CMAKE_BUILD_TYPE STREQUAL "Release")
    message("USE O3")
    target_compile_options(${PROJECT_NAME} PRIVATE -O3)
endif()
